package com.bj58.ecdata.dashboard.controllers;

import javax.servlet.http.HttpServletRequest;
import com.bj58.ecdata.dashboard.constant.EnumCate;
import com.bj58.ecdata.dashboard.databll.CalendarBLL;
import com.bj58.ecdata.dashboard.utils.MyServletRequestUtils;
import com.bj58.wf.mvc.ActionResult;
import com.bj58.wf.mvc.MvcController;
import com.bj58.wf.mvc.annotation.POST;
import com.bj58.wf.mvc.annotation.Path;

/**
 * 万年历看板 Ajax Controller
 * @author guoxue 2015-11-18
 */
@Path("/calendar/ajax")
public class CalendarAjaxController extends MvcController{
	
	@Path("/getCalFesLine")
	@POST
	public ActionResult getCalFesLine() {

		HttpServletRequest request = beat.getRequest();
		
		try {
			
			String businessName = MyServletRequestUtils.getStringParameter(request, "businessName", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate_option", "");
			String city = MyServletRequestUtils.getStringParameter(request, "city_option", "");
			String index = MyServletRequestUtils.getStringParameter(request, "index_Type", "");
			String festival = MyServletRequestUtils.getStringParameter(request, "festival_option", "");
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "dateGroup", "stat_date");
			String platform = MyServletRequestUtils.getStringParameter(request, "platform", "");
			
	     	EnumCate cateEnum = null;
			cateEnum = EnumCate.valueOf(businessName);
			String data = CalendarBLL.getCalendarFesLine(cateEnum,dateGroup,cate,city,index,festival,platform);
			//log.info(data);
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	
	@Path("/getCalSourceLine")
	@POST
	public ActionResult getCalSourceLine() {

		HttpServletRequest request = beat.getRequest();
		
		try {
			
			String businessName = MyServletRequestUtils.getStringParameter(request, "businessName", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate_option", "");
			String source = MyServletRequestUtils.getStringParameter(request, "source_option", "");
			String index = MyServletRequestUtils.getStringParameter(request, "index_Type", "");
			String festival = MyServletRequestUtils.getStringParameter(request, "festival_option", "");
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "dateGroup", "stat_date");
			String platform = MyServletRequestUtils.getStringParameter(request, "platform", "");
			
	     	EnumCate cateEnum = null;
			cateEnum = EnumCate.valueOf(businessName);
			String data = CalendarBLL.getCalSourceLine(cateEnum,dateGroup,cate,source,index,festival,platform);
			//log.info(data);
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	 
	
	@Path("/getSeasonCityLine")
	@POST
	public ActionResult getSeasonCityLine() {

		HttpServletRequest request = beat.getRequest();
		
		try {
			
			String businessName = MyServletRequestUtils.getStringParameter(request, "businessName", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate_option", "");
			String city = MyServletRequestUtils.getStringParameter(request, "city_option", "");
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "dateGroup", "stat_date");
			String platform = MyServletRequestUtils.getStringParameter(request, "platform", "");
			String index = MyServletRequestUtils.getStringParameter(request, "index_Type", "");
			
	     	EnumCate cateEnum = null;
			cateEnum = EnumCate.valueOf(businessName);
			String data = CalendarBLL.getSeasonCityLine(cateEnum,dateGroup,cate,city,platform,index);
			//log.info(data);
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	
	@Path("/getSeasonSourceLine")
	@POST
	public ActionResult getSeasonSourceLine() {

		HttpServletRequest request = beat.getRequest();	
		try {	
			String businessName = MyServletRequestUtils.getStringParameter(request, "businessName", "");
			String cate = MyServletRequestUtils.getStringParameter(request, "cate_option", "");
			String source = MyServletRequestUtils.getStringParameter(request, "source_option", "");
			String dateGroup = MyServletRequestUtils.getStringParameter(request, "dateGroup", "stat_date");
			String platform = MyServletRequestUtils.getStringParameter(request, "platform", "");
			String index = MyServletRequestUtils.getStringParameter(request, "index_Type", "");
			
	     	EnumCate cateEnum = null;
			cateEnum = EnumCate.valueOf(businessName);
			String data = CalendarBLL.getSeasonSourceLine(cateEnum,dateGroup,cate,source,platform,index);
  
			//log.info(data);
			
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	
	@Path("/getFunnelMonth")
	@POST
	public ActionResult getFunnelMonth() {
		
		HttpServletRequest request = beat.getRequest();	
		try {		
			String businessName = MyServletRequestUtils.getStringParameter(request, "businessName", "");
			String source = MyServletRequestUtils.getStringParameter(request, "source_option", "");
			String month_num = MyServletRequestUtils.getStringParameter(request, "month_num", "");
			String platform = MyServletRequestUtils.getStringParameter(request, "platform", "");
			String season_Type = MyServletRequestUtils.getStringParameter(request, "season_Type", "");
			
	     	EnumCate cateEnum = null;
			cateEnum = EnumCate.valueOf(businessName);
			String data = CalendarBLL.getFunnelMonth(cateEnum,source,month_num,season_Type,platform);
  
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
	
	@Path("/getFunnelWeek")
	@POST
	public ActionResult getFunnelWeek() {

		HttpServletRequest request = beat.getRequest();
		
		try {
			
			String businessName = MyServletRequestUtils.getStringParameter(request, "businessName", "");
			String source = MyServletRequestUtils.getStringParameter(request, "source_option", "");
			String week_day = MyServletRequestUtils.getStringParameter(request, "week_day", "");
			String platform = MyServletRequestUtils.getStringParameter(request, "platform", "");
			String season_Type = MyServletRequestUtils.getStringParameter(request, "season_Type", "");
			
	     	EnumCate cateEnum = null;
			cateEnum = EnumCate.valueOf(businessName);
			String data = CalendarBLL.getFunnelWeek(cateEnum,source,week_day,season_Type,platform);
  
			return ViewResult.jsonView(data);
		} catch (Exception e) {
			e.printStackTrace();
			return ViewResult.jsonView("{}");
		}
	}
}
